<?php
class content_infoModel extends baseModel{
    protected $table = 'content';

    //获取内容基本信息
    public function info($aid,$urltitle=false)
    {
        if(!$urltitle){
            $where='aid='.$aid;
        }else{
            $where='urltitle="'.$aid.'"';
        }

        return $this->find($where);
    }

    //完整内容
    public function info_data($aid,$category)
    {
        //内容信息SQL接口
        $ext_sql='';
        $ext_field='';
        $ext_where='';
        $api_sql=ApiHook('hook_content_info_sql',$category);
        if(!empty($api_sql)){
            foreach ($api_sql as $value) {
                $ext_sql.=$value['sql'];
                $ext_field.=$value['field'];
                $ext_where.=$value['where'];
            }
        }
        $sql="
            SELECT {$ext_field}B.content,A.*
            FROM {$this->model->pre}content A 
            LEFT JOIN {$this->model->pre}content_data B ON B.aid = A.aid
            {$ext_sql}
            WHERE A.aid={$aid}{$ext_where} LIMIT 1
        ";
        $info=$this->model->query($sql);
        return $info[0]; 

    }

    

    

}
